﻿using System;
using System.Collections.Generic;
using System.Text;
using BehaviorTrees;

namespace TestProject
{
	/// <summary>
	/// Base class for all tests.
	/// </summary>
	public class BaseTest
	{
		// these fields better won't be shared among test methods... they're just here
		// for the sake of not declaring these variables over and over again
		protected TestEntity entity;
		protected Node<TestEntity> node;
		protected Task<TestEntity> task;
		protected TaskResult result;
		/// <summary>
		/// Evaluates given node, and execute it till it finishes.
		/// </summary>
		/// <param name="seq"></param>
		/// <returns></returns>
		public TaskResult Run<E>(Node<E> node, E entity) where E : Entity
		{
			Task<E> task = node.Evaluate(entity);
			TaskResult result;
			do {
				result = task.Execute(entity, null);
			} while (result == TaskResult.Running);

			return result;
		}
	}
}
